//index.js
//获取应用实例


const app = getApp()
var QQMapWX = require('../../libas/qqmap-wx-jssdk')

var qqmapsdk = new QQMapWX({
  key: 'TDRBZ-EJQ6O-SELWK-SARDW-OBAOT-6JB5S'
});


wx.getLocation({
  type:'wg84',
  altitude: 'altitude',
})

Page({
  data: {
    // latitude,
    // longitude
  },

  btn() {

    wx.getLocation({
      type: 'wgs84',
      success: (res) => {
        console.log(res)
        //经纬度获取后
        const latitude = res.latitude //纬度
        const longitude = res.longitude // 经度
        qqmapsdk.reverseGeocoder({
          location: {
            latitude, //纬度
            longitude //经度
          },
          success: (data) => {
            console.log(data) 
          }
        })
      }
    }),
  
      wx.getLocation({
        success: res => {
          //调用接口 
          this.qqmapsdk.reverseGeocoder({
            location: {
              latitude: res.latitude,
              longitude: res.longitude
            },
            success: res => {
              let city = res.result.address_component.city
              //调用网络数据
              this.setData({
                city: city, //城市为获取的城市
                locationTipsText: "" //"点击获取当前位置"这句话就不显示了
              })
            }
          })
        }
      })
    
  },
  onLoad: function () {
    qqmapsdk = new QQMapWX({
      key: 'TDRBZ-EJQ6O-SELWK-SARDW-OBAOT-6JB5S'
    });

  },
  getUserInfo: function (e) {

  }
})